<template>
  <!-- header -->
  <div class="header main-container">
    <div class="logo">
      <img src="@/assets/images/zjl-logo.png" alt="" />
    </div>
    <div class="nav">
      <ul>
        <li :class="{ active: activeItem === 'home' }" @click="setActive('home')">
          首页
        </li>
        <li :class="{ active: activeItem === 'events' }" @click="setActive('events')">
          活动内容
        </li>
        <li :class="{ active: activeItem === 'schedule' }" @click="setActive('schedule')">
          日程安排
        </li>
        <li :class="{ active: activeItem === 'registration' }" @click="setActive('registration')">
          会议报名
        </li>
        <li :class="{ active: activeItem === 'exhibitions' }" @click="setActive('exhibitions')">
          展览活动
        </li>
        <li :class="{ active: activeItem === 'partners' }" @click="setActive('partners')">
          合作伙伴
        </li>
        <li :class="{ active: activeItem === 'news' }" @click="setActive('news')">
          新闻中心
        </li>
        <li :class="{ active: activeItem === 'services' }" @click="setActive('services')">
          服务中心
        </li>
        <li :class="{ active: activeItem === 'contact' }" @click="setActive('contact')">
          联系我们
        </li>
      </ul>
    </div>
    <div class="line"></div>
    <div class="icon">
      <img src="@/assets/images/icon_search.png" alt="" />
    </div>
  </div>
</template>

<script>
export default {
  name: "ForumHeader",
  data() {
    return {
      activeItem: "", // 用于存储当前被选中的项目
    };
  },
  methods: {
    setActive(item) {
      this.activeItem = item; // 设置当前被选中的项目
    },
  },
};
</script>

<style scoped>
/* header-start */
.header {
  height: 68px;
  display: flex;
  align-items: center;
}

.header img {
  width: 308px;
  height: 48px;
}

.header .nav {
  flex: 1;
}

.header ul {
  display: flex;
  margin-left: 118px;
  flex: 1;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  color: #666;
  cursor: pointer;
}

.line {
  width: 1px;
  height: 20px;
  background-color: #666;
  /* //margin: 0 25px; */
  margin-left: 26px;
  display: inline-block;
}

.header .icon {
  height: 20px;
  line-height: 20px;
}

.header .icon img {
  margin-left: 26px;
  width: 20px;
  height: 20px;
}

.nav ul li.active {
  /* //font-weight: bold ; */
  color: #004cea;
  position: relative;
  /* 添加这行 */
}

.nav ul li.active::after {
  content: "";
  position: absolute;
  bottom: -20px;
  /* 控制下划线位置 */
  left: 0;
  width: 100%;
  height: 2px;
  background-color: #004cea;
  /* 下划线颜色 */
}

/* header-end */
</style>